package com.ymatou.iapi.productsynces.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import com.ymatou.iapi.productsynces.parameter.es.EsGodProduct;
import com.ymatou.iapi.productsynces.parameter.es.EsProduct;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;

public class ESGodsearchCall extends  YmatouAutoTestCall{
	private static String opurl ="godproduct/_search";
	
	public ESGodsearchCall() {
		//super(EnvSetup.getSystemUrl("esquery"),opurl,"GET","JSON");
		super(EnvSetup.getSystemUrl("esgodquery"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	

	
	
	public EsGodProduct getEsProduct() throws JsonSyntaxException, JSONException
	{
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
		EsGodProduct esproduct = gson.fromJson(new JSONObject(getReturnData()).getJSONObject("hits").getJSONArray("hits").getJSONObject(0)
				.getJSONObject("_source").toString(), EsGodProduct.class);
		return esproduct;
	}
	
	
	
	
	
	
	
	
	
	public static void main(String[] args) throws Exception {
	}
	

}
